package com.renshenlianzhuangyuan.h5;

import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.widget.ImageView;

/**
 * 欢迎界面
 * 
 * @version 1.0 2014-03-22
 * @author 笑呵�?
 * 
 */
public class ActivityWelcome extends ActivityCore {
	private ImageView mIVWelcome;//

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		//getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
		setContentView(R.layout.activity_welcome);
		mIVWelcome = (ImageView) findViewById(R.id.iv_welcome);
		AlphaAnimation animation = new AlphaAnimation(1.0f, 1.0f);
		animation.setDuration(1000);
		animation.setAnimationListener(new AlphaAnimationListener());
		mIVWelcome.setAnimation(animation);
	}

	/**
	 * 透明度改变动画监�?
	 * 
	 * @author q
	 * 
	 */
	private class AlphaAnimationListener implements AnimationListener {

		@Override
		public void onAnimationEnd(Animation arg0) {
			skipToMain();
		}

		@Override
		public void onAnimationRepeat(Animation arg0) {
			// 重复
		}

		@Override
		public void onAnimationStart(Animation arg0) {

		}
	}

	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			return true;
		}

		return false;

	}

	/**
	 * 跳转到主界面
	 */
	private void skipToMain() {
		Class mClass = ActivityMain.class;
		Intent intent = new Intent(ActivityWelcome.this, mClass);
		startActivity(intent);
		finish();
		//overridePendingTransition(android.R.anim.slide_in_left,
		//		android.R.anim.slide_out_right);
	}

	public void onResume() {
		super.onResume();
	}
}
